package com.junmoo.www.utils;

import lombok.*;

@Builder
@ToString
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private int code;
    private String msg;
    private String status;
    private Object data;

    public static R setR(int code,String status,String msg,Object data){
        return R.builder().code(code).status(status).msg(msg).data(data).build();
    }
    public static R success(){
        return setR(200,"2xx","success",null);
    }

    public static R success(Object data){
        return setR(200,"2xx","success",data);
    }

    public static R success(String msg,Object data){
        return setR(200,"2xx",msg,data);
    }

    public static R error(){
        return setR(500,"5xx","error",null);
    }

    public static R error(Object error){
        return setR(500,"5xx","error",error);
    }

    public static R error(String msg){
        return setR(500,"5xx",msg,null);
    }

    public static R error(String msg,Object error){
        return setR(500,"5xx",msg,error);
    }
}
